module System.Console;
private import std.string;
private import std.utf;
private import std.format;


version ( Win32_release ) {
	private import std.file;
	public final class Console{
		private static char[] _logfile = "log.txt";
		private static this(){
			if ( exists( _logfile ) ) remove( _logfile );
			write(_logfile , "LOG START!\n");
		}
		public static void w(char[] str){
			Console.write( str );
		} //
		public static void wn(char[] str){
			Console.writeln( str );
		} //
		public static void write(...) {
			char[] _str = "";
			void _putc(dchar c)	{
				auto tmp = [c];
				_str ~= toUTF8(tmp);
			}
			doFormat(&_putc, _arguments, _argptr);
			append( _logfile , _str );
		} //

		public static void writeln(...) {
			char[] _str = "";
			void _putc(dchar c)	{
				auto tmp = [c];
				_str ~= toUTF8(tmp);
			}
			doFormat(&_putc, _arguments, _argptr);
			append( _logfile , _str ~ "\n" );
		} //

	} //
} else {
	public final class Console{
		public static void w(char[] str){
			Console.write( str );
		} //
		public static void wn(char[] str){
			Console.writeln( str );
		} //
		public static void write(...) {
			char[] _str = "";
			void _putc(dchar c)	{
				auto tmp = [c];
				_str ~= toUTF8(tmp);
			}
			doFormat(&_putc, _arguments, _argptr);
			printf( toStringz( _str ) );
		} //

		public static void writeln(...) {
			char[] _str = "";
			void _putc(dchar c)	{
				auto tmp = [c];
				_str ~= toUTF8(tmp);
			}
			doFormat(&_putc, _arguments, _argptr);
			printf( toStringz( _str ) );
			printf( "\n" );
		} //

	} //
}

